<?php
/**
 * Groups module for XOOPS
 *
 * You may not change or alter any portion of this comment or credits
 * of supporting developers from this source code or any supporting source code 
 * which is considered copyrighted (c) material of the original comment or credit authors.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @copyright       The Groups Project http://code.google.com/p/groupsforxoops/
 * @license         http://www.fsf.org/copyleft/gpl.html GNU public license
 * @package         groups
 * @since           2.3.0
 * @author          Hui Xiao < xh.8326@gmail.com >
 * @version         $Id: admin.php Sat Jul 18 12:45:39 CST 2009
 */

include "conf.inc";

$group_id = isset($_GET["id"]) ? trim($_GET["id"]) : 0 ;
$start = isset($_GET["start"]) ? trim($_GET["start"]) : 0 ;
$fct = isset($_GET["f"]) ? trim($_GET["f"]) : "" ;

/** 加载相关的类文件 **/
$group_handler = xoops_getmodulehandler("group");
$column_handler = xoops_getmodulehandler("column");
$memb_handler = xoops_getmodulehandler("memb");

/** 载入语言包 **/
xoops_loadLanguage("user","groups");

/** 检查来访者权限 **/
if ( empty($group_id) ) header("Location: index.php");
$group_obj = $group_handler->get($group_id);
if ( !is_object($group_obj) )	header("Location: index.php");
if (  empty($xoopsUser) || !is_object($xoopsUser) || $group_obj->getVar("uid") != $xoopsUser->getVar("uid") ) {
	$fct = "noperm";
}

/** 加载模板文件 **/
$xoopsOption["xoops_pagetitle"] = $xoopsModuleConfig["groupstitle"];
$xoopsOption["template_main"] = "groups_us_index.html";
include "header.php";
$subTemplate = "";
switch ($fct) {
    case "perm":
        $formUrl = _GROUPS_URL."/user/action.user.php";
        $groups_arr = $groups_obj->getValues();
        include_once(dirname(__FILE__)."/user/form.us.groups.permission.php");
    break;
    
    case "column":
        $formUrl = _GROUPS_URL."/user/action.user.php";
        include_once(dirname(__FILE__)."/user/form.us.column.edit.php");
        $list = $column_handler->getColumnList($group_id);
        $xoopsTpl->assign("column_list",$list);
    break;
        
    case "member":
        $limit = 40 ;
        $extra = "fct={$fct}&gid={$group_id}";
        $list = $members_handler->getMemberslist($group_id,$start,$limit,$extra,false);
        $xoopsTpl->assign(array("members"=>$list["list"],"pagenav"=>$list["pagenav"]));
    break;
    
    case "remove":
        $formUrl = _GROUPS_URL."/user/action.user.php";
        $confirm = xoops_groups_confirm(array("group_id"=>$group_id,"ac"=>"removegroup"),$formUrl,_GP_CONFIRM_DELGROUP);
        $xoopsTpl->assign(array("confirm_form"=>$confirm));
    break;
    
    default:
        $formUrl = _GROUPS_URL."/user/action.user.php";
		$groups_arr = $group_obj->getValues();
//		include(dirname(__FILE__)."/user/form.us.groups.edit.php");
		$xoopsTpl->assign("groupedit",_US_EDIT_GROUP);
		$subTemplate = "edit";
}
$xoopsTpl->assign(array("group"=>$group_obj,"subTemplate"=>$subTemplate));
include "footer.php";
?>